<template>
    <div class="app-container">
        <div class="header">
            <div class="title-container">
                <h3 class="title">AI起名</h3>
            </div>
        </div>
        <div class="content">
            <div class="form-group">
                <h2 for="dad-name">爸爸的姓:</h2>
                <input type="text" id="dad-name" class="input-field" v-model="dadName" placeholder="请输入爸爸的姓" />
            </div>
            <div class="form-group">
                <h2 for="mom-name">妈妈的姓:</h2>
                <input type="text" id="mom-name" class="input-field" v-model="momName" placeholder="请输入妈妈的姓" />
            </div>
            <button class="generate-button" @click="generateName">生成名字</button>
        </div>
        <div v-if="showPopup" class="popup">
            <h2 class="popup-title">生成的名字</h2>
            <p class="popup-content">{{ generatedName }}</p>
            <button class="popup-close-button" @click="closePopup">关闭</button>
        </div>
        <div v-if="initPopup" class="popup">
            <div class="form-group">
                <h2 for="mom-name">输入最终生成的名字</h2>
                <input type="text" id="mom-name" class="input-field" v-model="generatedName" placeholder="请输入想要的名字" />
            </div>
            <button class="generate-button" @click="initPopup = false">确定</button>
        </div>
    </div>
</template>  
  
<script>
export default {
    data () {
        return {
            dadName: '',
            momName: '',
            generatedName: '',
            showPopup: false,
            initPopup: true,
        };
    },
    methods: {
        goBack () {
            // 导航回上一页的逻辑（需要根据实际项目情况实现）  
            window.history.back();
        },
        generateName () {
            // 这里是生成名字的逻辑，暂时只是简单拼接父母的姓，实际应用中可以根据需要实现更复杂的逻辑  
            this.showPopup = true;
        },
        closePopup () {
            this.showPopup = false;
        }
    }
};  
</script>  

<style lang="scss" scoped>
$fontSizeBase: 16px; // 基础字体大小  
$blueThemeColor: #007bff; // 蓝色主题色  

html {
    font-size: $fontSizeBase;
}

.app-container {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    text-align: center;
    background-color: #f7f7f7;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: $blueThemeColor;
    color: #fff;
    padding: 1rem;
}

.title-container {
    flex: 1;
    text-align: center;
}

.title {
    margin: 0;
    font-size: 1.5rem;
}

.back-button {
    font-size: 1.25rem;
    background-color: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.form-group {
    margin-bottom: 1rem;

    input {
        width: auto;
    }
}

.input-field {
    font-size: 1.25rem;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    max-width: 300px;
}

.generate-button {
    font-size: 1.25rem;
    padding: 1rem;
    border: none;
    width: 80%;
    margin: 1rem auto;
    border-radius: 4px;
    background-color: $blueThemeColor;
    color: #fff;
    cursor: pointer;
}

.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
    padding: 20px;
    box-sizing: border-box;
    min-width: 200px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    overflow: auto;
}

.popup-title {
    margin: 0 0 10px;
    font-size: 1.25rem;
}

.popup-content {
    font-size: 1.1rem;
    margin: 0 0 10px;
}

.popup-close-button {
    font-size: 1rem;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    background-color: #f44336; // 红色背景  
    color: #fff;
    cursor: pointer;
    transition: background-color 0.3s ease;

    &:hover {
        background-color: #d32f2f; // 鼠标悬停时颜色加深  
    }
}

// 当弹窗显示时，确保页面不能滚动  
body.no-scroll {
    overflow: hidden;
}
</style>  
